import Vue from 'vue';
import Vuex from 'vuex';
const camelCase = require('camelcase');

Vue.use(Vuex);

/*
* 获取moudules文件下所有js文件
* 自动加载
* */
const context = require.context('./modules', false, /\.js$/);
const moduleStores = {};

context.keys().forEach(key => {
    // 移除.js后缀
    const fileName = key.slice(2, -3);
    // 转为驼峰命名
    const fileNameInCamelCase = camelCase(fileName);
    moduleStores[fileNameInCamelCase] = context(key).default;
});
export default new Vuex.Store({
    modules: {
        ...moduleStores,
    },
    getters: {
        //pageOptions: state => state.backend.pageOptions,
    }
});
